﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Vaffanculo.Service;
using Vaffanculo.Model.Entities;

namespace Vaffanculo.Presentation.Component.UserControl
{
    /// <summary>
    /// Interaction logic for NewProject.xaml
    /// </summary>
    public partial class NewProject : Window
    {
        MainWindow mainWindow;

        public NewProject(MainWindow mainWindow)
        {
            this.mainWindow = mainWindow;
            InitializeComponent();
        }

        private void CreateClick(object sender, RoutedEventArgs e)
        {
            ProjectService serv = new ProjectService();
            Project project = new Project()
            {            
                Code = "001",
                CreationDate = DateTime.Now,
                DatabaseIp = "192.168.1.211",
                DatabaseName = "myDatabase",
                DatabasePassword = "admin123",
                DatabaseType = "sql_server_express",
                DatabaseUser = "admin",
                Description = "first test",
                ModifyDate = DateTime.Now,
                Name = txName.Text,
                Source = "source_service"
            };
            project = serv.NewProject(project);

            mainWindow.BuildTreeView(project);
            this.Close();
        }

        private void CancelClick(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void Window_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed)
                this.DragMove();
        }

        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
